home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97b.txt / 000099_icon-group-sender _Mon Oct 27 09:46:01 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  3KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by cheltenham.cs.arizona.edu (8.8.7/8.8.7) with SMTP id JAA00384
  4.     for <icon-group-addresses@cheltenham.CS.Arizona.EDU>; Mon, 27 Oct 1997 09:46:00 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA26110; Mon, 27 Oct 1997 09:46:00 -0700
  7. To: icon-group@cs.arizona.edu
  8. Date: Sat, 25 Oct 1997 17:49:51 +1000
  9. From: Stuart.Robinson@anu.edu.au (Stuart Robinson)
  10. Message-Id: <Stuart.Robinson-2510971749520001@asianstmg-229.anu.edu.au>
  11. Organization: ANU
  12. Sender: icon-group-request@cs.arizona.edu
  13. Subject: one more question
  14. Errors-To: icon-group-errors@cs.arizona.edu
  15. Status: RO
  16.  
  17. Again, thanks to everyone for their help with what is admittedly a pretty
  18. trivial matter. It seems the key to my problem was tables, a structure
  19. that I didn't understand until someone pointed out their necessity and I
  20. read the appropriate section in _The Icon Programming Language_.  (I
  21. mention this fact only to prevent people from thinking that I just want
  22. solutions handed to me on a silver platter)
  23.  
  24. Anyhow, I just have one more question:
  25.  
  26. Look at the program attached below (which is my modification of the
  27. proposed solution sent to me by Steven Wampler).  The problem with it is
  28. this: I want to sort on the value being counted and not the counts
  29. themselves.  However, the sorting is fairly "dumb" and puts e.g. "4" after
  30. e.g. "392" (looking at only the first digit).  Is there a quick fix?
  31.  
  32. Cheers,
  33. Stuart
  34.  
  35. ############################################################################
  36. #
  37. #       File:           tabl_values.icn
  38. #       Subject:        program written to do number count
  39. #       Author:         Steven Wampler (w/ modifications by Stuart Robinson)
  40. #       Date:           25 October 1997
  41. #
  42. ############################################################################
  43. #
  44. #               The main revision consists of the if clause in the procedure 
  45. #       countnums(), which now looks for lines with O's that had no 
  46. #       referential index and therefore have no lookback value.
  47. #
  48. ############################################################################
  49. procedure main()
  50.  
  51.         counts := sort( countnums(), 1 ) # HEREIN LIES THE PROBLEM!!!
  52.  
  53.         every i := *counts to 1 by -1 do
  54.                 {
  55.                 write( counts[i][1] || "\t" || counts[i][2] )
  56.                 }
  57. end
  58.  
  59. procedure countnums()
  60.  
  61.         numcount := table(0)
  62.  
  63.         while line := read() do
  64.                 line ?
  65.                         {
  66.                         if find( "no ref index" )
  67.                                 then numcount[ "NA" ] +:= 1
  68.                         else
  69.                                 while tab( upto( &digits ) ) do
  70.                                         numcount[ tab( many( &digits ) ) ] +:= 1
  71.                         }
  72.  
  73.         return numcount
  74. end
  75.  
  76. -- 
  77. Stuart Robinson <Stuart.Robinson@nospam.anu.edu.au>
  78. The Australian National University
  79. *TO REPLY, REMOVE "nospam." FROM E-MAIL ADDRESS GIVEN ABOVE
  80.